home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
imb9110.zip
/
BT.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-10-01
|
2KB
|
88 lines
'****************************************************
'* BT.BAS - test bit manuipulation routines *
'****************************************************
DECLARE SUB PrintBitList (BitList%)
' $INCLUDE: 'BITLIST.BI'
' Begin main module
CLS
RANDOMIZE TIMER
A% = blCreate(80)
B% = blCreate(80)
C% = blCreate(80)
IF A% = NULL OR B% = NULL OR C% = NULL THEN
PRINT "ERROR: cannot create bitlists!"
END
END IF
' Create a random bitlist
FOR I% = 1 TO 79
X% = blSetBit(A%, (I%), (RND(1) < .4))
NEXT I%
PRINT : PRINT "The first random bitlist:"
PrintBitList A%
' Copy and invert it
X% = blListOp(blCOPY, B%, A%)
X% = blListOp(blINVERT, B%, 0)
PRINT : PRINT "The inversion of the 1st list of bits:"
PrintBitList B%
' Create a random bitlist
FOR I% = 1 TO 79
X% = blSetBit(C%, (I%), (RND(1) < .4))
NEXT I%
PRINT : PRINT "Another random bitlist:"
PrintBitList C%
' Show the union of the orig & random lists
X% = blListOp(blUNION, C%, A%)
PRINT : PRINT "The union of the two random bit lists:"
PrintBitList C%
' Show intersection of inverted original & random lists
X% = blListOp(blINTERSECT, C%, B%)
PRINT
PRINT "Intersection of the first list inverted and the 2nd list"
PrintBitList C%
' Clear a list
X% = blListOp(blCLEAR, B%, 0)
PRINT : PRINT "A cleared bitlist:"
PrintBitList B%
' Set a list
X% = blListOp(blSET, B%, 0)
PRINT : PRINT "A set bitlist:"
PrintBitList B%
' Delete the bitlists
blDestroy A%
blDestroy B%
blDestroy C%
END
SUB PrintBitList (bl%) STATIC
'****************************************************
'* PrintBitList - subprogram to display a bit list *
'****************************************************
FOR I% = 1 TO 79
IF blGetBit(bl%, (I%)) THEN
PRINT "T";
ELSEIF I% MOD 10 = 0 THEN
PRINT CHR$(I% \ 10 + ASC("0"));
ELSEIF I% MOD 5 = 0 THEN
PRINT "+";
ELSE
PRINT "-";
END IF
NEXT I%
PRINT
END SUB